/*
 * FileName: UserDao.java
 *
 *  
 */
package com.mrc.core.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.mrc.core.base.BaseDao;
import com.mrc.core.base.Constant;
import com.mrc.core.model.SysUser;

@Repository
public class SysUserDao extends BaseDao<SysUser> {

    /**
     * @param entityClass
     */
    protected SysUserDao() {
        super(SysUser.class);
    }

    /**
     * 查询所有正常状态的用户
     * @return
     */
    public List<SysUser> list() {
        //        return getHibernateTemplate().find(" from SysUser u where u.status=1 ");
        return super.queryHQL(" from SysUser u where u.status=" + Constant.STATUS_NORMAL);
    }

    /**
     * 根据手机号码查询用户
     * @param userName
     * @return
     */
    public SysUser findByMobile(String userMobile) {
        List<SysUser> list = super.queryHQL(" from SysUser u where u.mobile=?", userMobile);
        return list.size() > 0 ? list.get(0) : null;
    }

}
